<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .wrapper {
        position: relative;
        width: 600px;
        height: 400px;
        border: 5px solid black;
        margin: 0 auto;
      }

      .box1,
      .box2,
      .box3 {
        display: inline-block;
        width: 150px;
        height: 150px;
        border: 5px dotted black;
        position: absolute;
      }
      .box1 {
        background-color: red;
        left: 50px;
        z-index: 3;
      }
      .box2 {
        left: 100px;
        top: 50px;
        background-color: green;
        /*z-index: -1;*/
        z-index: -20;
      }
      .box3 {
        background-color: blue;
        left: 150px;
        z-index: 1;
      }
    </style>
  </head>

  <body>
    <div class="wrapper">
      <div class="box1"></div>
      <div class="box2"></div>
      <div class="box3"></div>
    </div>
  </body>
</html>
